-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
annotate alloc
on unixes.
#548
Conversation
src/snmalloc/mem/localalloc.h
Outdated
#if defined(_MSC_VER) | ||
# define ALLOCATOR __declspec(allocator) __declspec(restrict) | ||
#elif defined(__GNUC__) | ||
# define ALLOCATOR __attribute__((__malloc__)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't that be
# define ALLOCATOR __attribute__((__malloc__)) | |
# define ALLOCATOR __attribute__((malloc)) |
and probably we want to do something like
# define ALLOCATOR __attribute__((__malloc__)) | |
# define ALLOCATOR __attribute__((malloc, malloc(dealloc))) |
to associate the deallocator, but perhaps that means it has to be
# define ALLOCATOR(dealloc) __attribute__((malloc, malloc(dealloc)))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define ALLOCATOR(dealloc) attribute((malloc, malloc(dealloc)))
I thought of that but clang does not support this form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This form is somewhat useful for static analysis but it likely to lead to miscompiles as currently proposed to be integrated in LLVM. The problem is that the compiler doesn't track the hierarchy of allocators that are in use. An allocation path might have a call to alloc, whereas the deallocation path might end up being inlined to the point where it knows to call munmap
or similar. I think that isn't a problem for the most recent snmalloc (we never hand actually unmap memory) but it might be a problem if we add the same attributes for the ranges (if you do a large thread-local allocation and free then we'll still hit the allocator path but may push it back into the thread's large chunk cache on deallocation and so enough might be inlined to confuse the optimiser into thinking that you've allocated with one allocator and freed with another).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @nwf-msr are you happy with the updates?
LGTM |
ping :) |
Sorry, I forgot about this one. |
No description provided.